/*
Reverse digits of an integer.

Example1: x = 123, return 321
Example2: x = -123, return -321
 */

class Solution {
public:
    int reverse(int x) {
    	int result=0;
    	while(abs(x) > 0){
    		result *=10;
    		result +=x%10;
    		x = x/10;
    	}
    	return result;

    }
};